<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./node_modules/vue/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- v-on:事件名='方法' 小括号可以写，也可以不写-->
        <button v-on:click="getHome()">获取今天作业</button>

        <!-- v-on: 可以简写成@ -->
        <button @click="getHome">获取今天作业</button>

        <!-- 带参数 -->
        <button @click="sum(2,3)">计算2+3</button>

        <!-- 如果事件函数中的逻辑代码就一句，可以省略封装方法 -->
        <button @click=" name = '李易峰'">换个偶像</button>
        <h3>{{name}}</h3>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                name: "吴亦凡"
            },
            methods: {
                getHome() {
                    console.log("今天代码敲3遍，然后有两个作业");
                },
                sum(a, b) {
                    console.log(a + b);
                },
                change() {
                    this.name = '李易峰'
                }
            }
        })
    </script>
</body>

</html>